package com.ourteam.product.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.ui.dao.ProductUIImageDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUIImageBean;

public class ProductUIImageSearchModel extends AbstractSearchModel<ProductUIImageDAOQueryBean> {

	private Long domainId;

	private String imageCode;

	public Long getDomainId() {
		return domainId;
	}

	public void setDomainId(Long domainId) {
		this.domainId = domainId;
	}

	public String getImageCode() {
		return imageCode;
	}

	public void setImageCode(String imageCode) {
		this.imageCode = imageCode;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductUIImageBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductUIImageDAOQueryBean queryBean) throws Exception {

		ProductUIImageDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (this.domainId != null && this.domainId != 0) {
			criteria.andDomainIdEqualTo(this.domainId);
		}

		if (StringUtils.isNotBlank(imageCode)) {
			criteria.andImageCodeLike(imageCode);
		}
	}

}
